package com.hu.jie.mywallpager.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.widget.SimpleCursorAdapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.hu.jie.mywallpager.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class MySettingFragment extends Fragment {

    private TextView tv;
    private ListView lv;
    private List<HashMap<String,Object>> list;
    public MySettingFragment() {
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        return inflater.inflate(R.layout.fragment_my_setting, container, false);
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        tv = (TextView) view.findViewById(R.id.textView);
        tv.setText("更多");
        list = new ArrayList<HashMap<String,Object>>();
        lv = (ListView) view.findViewById(R.id.listview4);
        initData();
        //适配器
        SimpleAdapter adapter = new SimpleAdapter(getContext(),list,R.layout.layout_mysetting,
                new String[]{"name","image"},new int[]{R.id.textsetting,R.id.imagesetting});
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            }
        });
    }
    //初始化数据源
    private void initData() {
        HashMap<String,Object> map1 = new HashMap<String,Object>();
        map1.put("name","我的收藏");
        map1.put("image",R.mipmap.arrow);
        list.add(map1);

        HashMap<String,Object> map2 = new HashMap<String,Object>();
        map2.put("name","我的下载");
        map2.put("image",R.mipmap.arrow);
        list.add(map2);

        HashMap<String,Object> map3 = new HashMap<String,Object>();
        map3.put("name","推荐给好友");
        map3.put("image",R.mipmap.arrow);
        list.add(map3);

        HashMap<String,Object> map4 = new HashMap<String,Object>();
        map4.put("name","给个好评");
        map4.put("image",R.mipmap.arrow);
        list.add(map4);

        HashMap<String,Object> map5 = new HashMap<String,Object>();
        map5.put("name","设置");
        map5.put("image",R.mipmap.arrow);
        list.add(map5);
    }

}
